<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>四则运算</title>
	</head>
	<body>
		
		<input name="btn" type="button" value="计算两数运算结果" 
			onclick="oper(prompt('请输入一个数：',''),prompt('请再输入一个数：',''), prompt('请输入一运算符：','') )"/>
		<script type="text/javascript" charset="UTF-8">
			function oper(A,B,c) {
				var result = 0;
				var a = parseFloat(A);  //prompt的输入的是字符串，需要转换
				var b = parseFloat(B);
				if(c == "+") {
					result = (a + b);  
				} else if (c == "-"){
					result = (a - b);
				}else if (c == "*"){
					result = (a * b);
				}else if (c == "/"){
					result = (a / b);
				}
				document.write("结果是：" + result);
				alert("结果是：" + result); 
				
			}
		</script> 
	</body>
</html>
